<template>
  <h1>登陆中...</h1>
</template>

<script setup>
import {useRouter} from "vue-router";
import axios from "axios";
import {reqInstance} from "@/utils/request/index.js";
import {useLoginStore} from "@/sotre/useLoginStore.js";
const loginStore = useLoginStore()
// 读取 url-path 的 code
const r = useRouter()
console.log(r.currentRoute)
const code = r.currentRoute.value?.query?.code
if (code !== undefined) {
  reqInstance({
    url:"/auth/login",
    method:"post",
    params:{
      code,
    }
    // headers:{},
    // data:{
    //   code,
    // }
  }).then((res)=>{
    loginStore.set(res.data)
    r.push({name:"docker"})
  })

} else {
  // 如果没有获取到 code 则跳转 404
  r.push({name:"404"})
}

</script>

<style scoped></style>